package com.example.springbootdemo.异步注解失效测试.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class PrintTwo {
    @Async("asyncExecutors")
    public void java() {
        for (int i = 0; i < 20; i++) {
            try {
                Thread.sleep(1000);
                System.out.println("Async++++++++子线程java名："+Thread.currentThread().getName());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(i + "hello java");
        }
    }
    @Async("asyncExecutors")
    public void python() {
        for (int i = 0; i < 20; i++) {
            try {
                Thread.sleep(1000);
                System.out.println("Async++++++++子线程java名："+Thread.currentThread().getName());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(i + "hello python");
        }
    }
}
